package com.unbox.common.aspect;
import com.unbox.common.annotation.log.UnboxDefaulttLog;
import com.unbox.common.util.UnBoxUtils;
import com.unbox.common.util.UnboxLog;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;

/**
 * 日志收集
 */
@Aspect
@Component
@Import(UnboxDefaulttLog.class)
public class UnboxLogAspet {
    // 国际化日志输出
    UnboxLog unboxLog = new UnBoxUtils.LocaleMessageLog();

    public UnboxLogAspet() {
        unboxLog.info("log.info.aop.msg");
    }

    @Autowired
    UnboxLogHander unboxLogHander;

    // 定义一个切入点
    @Pointcut("@annotation(com.unbox.common.annotation.Log)")
    private void cut(){}

    @Around(value = "cut()")
    public Object logs(ProceedingJoinPoint joinPoint) {
       return unboxLogHander.hander(joinPoint);
    }
}
